package com.viphome.automic;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by wangzhanjin on 2018/3/27.
 */
public class AtomicIntegerDetailsTests {

    public static void main(String[] args) {
        /**
         * create
         */
        AtomicInteger i = new AtomicInteger();
        System.out.println(i.get());

        /**
         * set
         */
        i = new AtomicInteger(10);
        System.out.println(i.get());

        i.set(12);
        System.out.println(i.get());

        /**
         * get and set
         */
        AtomicInteger getAndSet = new AtomicInteger(10);
        int result = getAndSet.getAndAdd(10);
        System.out.println(result);
        System.out.println(getAndSet.get());

    }


}